package com.yunfei.utils.procedure;
import com.yunfei.bo.smrz.HeGeTouZiZheRenZhengBo;
import com.yunfei.bo.smrz.ZhuanYeTouZiZheRenZhengBo;
import com.yunfei.utils.string.StringUtil;
import oracle.jdbc.OracleTypes;
import org.springframework.transaction.annotation.Transactional;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
/**
 * @program: zntg_v2
 * @description:专业投资者认证存储过程
 * @author: zhengyunfei
 * @create: 2018-12-03 17:02
 **/
public class ZhuanYeTouZiZheRenZhengProcedure {
    /**
     PKG_YL_INTERFACE.sp_addinvestorreq
     输入参数（按顺序）：
     p_custno       in varchar2, --客户编号
     p_investtype   in varchar2, --投资者类型 默认 1：普通投资者
     p_provetype    in varchar2, --证明类型(1资产证明 2收入证明 3-投资经验承诺函)
     p_provebalance in number, --证明金额
     p_systemfrom   in varchar2, --来源系统--默认5:APP
     输出参数（按顺序）：
     p_reasoncode   out varchar2, --处理结果 0:失败 1成功 注意：当p_reasoncode  = 1 时 p_reasoninfo返回序列号
     p_reasoninfo   out varchar2 --结果描述
     **/
    @Transactional
    public ShiMingRenZhengProcedureReturnInfo save(ZhuanYeTouZiZheRenZhengBo param, Connection conn){
        ShiMingRenZhengProcedureReturnInfo renZhengProcedureReturnInfo=null;
        //输入参数
        String custNo=param.getpCustno();
        String pInvestType="1";
        String pProvetype=param.getpProvetype();//证明类型
        String pProvebalance=param.getpProvebalance();//证明类型
        //输出参数
        String pReasonCode;//处理结果:除1以外失败 1成功
        String pReasonInfo;//处理结果:结果描述
        String pReasonCode2;//处理结果:返回实名认证对应附件输出编号
        if(!StringUtil.isNullOrEmpty(custNo)){
            try {
                String sql = "call PKG_YL_INTERFACE.sp_addinvestorreq(?,?,?,?,?,?,?)";
                CallableStatement call = null;
                call = conn.prepareCall(sql);
                call.setString(1,custNo);
                call.setString(2,pInvestType);
                call.setString(3,pProvetype);
                call.setString(4,pProvebalance);
                call.setString(5,"5");//--默认5:APP
                call.registerOutParameter(6, OracleTypes.VARCHAR);
                call.registerOutParameter(7, OracleTypes.VARCHAR);
                call.execute();
                pReasonCode = call.getString(6);
                pReasonInfo = call.getString(7);
                renZhengProcedureReturnInfo=new ShiMingRenZhengProcedureReturnInfo();
                renZhengProcedureReturnInfo.setpReasonCode(pReasonCode);
                renZhengProcedureReturnInfo.setpReasonInfo(pReasonInfo);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return renZhengProcedureReturnInfo;
    }


}
